package com.yfp.goods.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.common.core.web.page.TableDataInfo;
import com.yfp.common.security.annotation.InnerAuth;
import com.yfp.goods.domain.dto.GoodsSearchNameDto;
import com.yfp.goods.service.AppletService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "小程序套餐相关接口")
@RestController
@RequestMapping("rpc")
public class AppletGoodsController extends BaseController {

    @Resource
    private AppletService appletService;

    @Operation(summary = "套餐信息获取- 获取套餐的标签接口信息")
    @GetMapping("combo/label/search/basic_info")
    @InnerAuth
    public TableDataInfo comboLabelSearchBasicInfo(String word, Integer pageIndex, Integer pageSize) {
        startPage();
        return getDataTable(appletService.comboLabelSearchBasicInfo(word));
    }


    @Operation(summary = "套餐信息获取- 筛选套餐基础数据")
    @GetMapping("combo/limit/basic_info")
    @InnerAuth
    public TableDataInfo comboLimitBasicInfo(String word, Integer pageIndex, Integer pageSize) {
        startPage();
        return getDataTable(appletService.comboLimitBasicInfo(word));
    }

    @Operation(summary = "套餐信息获取- 搜索套餐名称")
    @GetMapping("goods/search/name")
    @InnerAuth
    public List<GoodsSearchNameDto> goodsSearchName(@Valid @Parameter(name = "word") String word) {
        return appletService.goodsSearchName(word);
    }

    @Operation(summary = "套餐信息获取- 根据Id获取套餐名称")
    @GetMapping("combo/name/by_id")
    @InnerAuth
    public R comboNameById(@Valid @Parameter(name = "comboId") String comboId) {
        return R.ok(appletService.comboNameById(comboId));
    }


    @Operation(summary = "套餐信息获取- 根据Id获取套餐详细信息")
    @GetMapping("combo/user_view/by_id")
    @InnerAuth
    public R comboUserViewById(@Valid @Parameter(name = "comboId")  String comboId) {
        return R.ok(appletService.comboUserViewById(comboId));
    }

}